package com.feng.show.controller;


import com.feng.show.comm.ResponseCode;
import com.feng.show.comm.ServerResponse;
import com.feng.show.entity.ProductArea;
import com.feng.show.service.IProductAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/productArea")
public class ProductAreaController {
    /*
    产地
     */

    @Autowired
    private IProductAreaService productAreaSerViceImpl;


    @PostMapping("/add")
    public ServerResponse<String> label(

            @RequestParam(value = "areaName") String areaName,
            @RequestParam(value = "areaDes") String  areaDes,
            @RequestParam(value = "userId") String userId)

    {

        if(areaDes==null||areaDes==null||userId==null){
            return ServerResponse.createByErrorMsg("请求参数错误");
        }
        return productAreaSerViceImpl.addProductArea(areaName,areaDes,userId);

    }

    @PostMapping("/getAreaList")
    public ServerResponse<List<ProductArea>> getProductAreaList(

            @RequestParam(value = "userId") String userId)

    {

        userId="10001";
        if(userId==null){
            return ServerResponse.createByErrorCodeMessage(ResponseCode.ERROR.getCode(),"参数错误");

        }else{
            return productAreaSerViceImpl.getAreaList(userId) ;
        }

    }










//        if(no==null||name==null||des==null){
//            return ServerResponse.createByErrorCodeMessage(ResponseCode.ERROR.getCode(),"参数错误");
//
//        }else{
//            return addProductTypeService.addProductType(name,no,des);
//        }

    }
//
//    @PostMapping("getProductTypeList")
//    public ServerResponse<List<ProductType>> getProductTypeList(
//
//            @RequestParam(value = "userId") String userId)
//
//    {
//
//        userId="10001";
//        if(userId==null){
//            return ServerResponse.createByErrorCodeMessage(ResponseCode.ERROR.getCode(),"参数错误");
//
//        }else{
//            return addProductTypeService.getProductTypeList(userId);
//        }
//
//    }








